import request from '@/utils/request'

export function getCustomerList(params) {
  const data = {
    'search_value': params.search_key,
    'min_consume': params.min_consume,
    'max_consume': params.max_consume,
    'page': params.page,
    'customer_type': params.customer_type,
    'customer_attribute': params.customer_attribute,
    'area_type': params.area_type,
    'limit': params.limit
  }
  return request({
    url: '/hospital/customer/list',
    method: 'get',
    params: data
  })
}

export function getPotentialCustomerList(params) {
  const data = {
    'search_value': params.search_key,
    'user_area': params.user_area,
    'first_source': params.first_source,
    'start_behavior_count': params.start_behavior_count,
    'end_behavior_count': params.end_behavior_count,
    'behavior_start_time': params.behavior_start_time,
    'behavior_end_time': params.behavior_end_time,
    'start_last_browse_time': params.start_last_browse_time,
    'end_last_browse_time': params.end_last_browse_time,
    'start_last_login_time': params.start_last_login_time,
    'end_last_login_time': params.end_last_login_time,
    'min_consume': params.min_consume,
    'max_consume': params.max_consume,
    'page': params.page,
    'limit': params.limit
  }
  return request({
    url: '/hospital/customer/potential-list',
    method: 'get',
    params: data
  })
}

export function getConsultationCustomerList(params) {
  const data = {
    'search_value': params.search_key,
    'user_area': params.user_area,
    'first_source': params.first_source,
    'start_behavior_count': params.start_behavior_count,
    'end_behavior_count': params.end_behavior_count,
    'start_last_browse_time': params.start_last_browse_time,
    'end_last_browse_time': params.end_last_browse_time,
    'start_last_login_time': params.start_last_login_time,
    'end_last_login_time': params.end_last_login_time,
    'start_first_consultation_time': params.start_first_consultation_time,
    'end_first_consultation_time': params.end_first_consultation_time,
    'start_last_consultation_time': params.start_last_consultation_time,
    'end_last_consultation_time': params.end_last_consultation_time,
    'min_consume': params.min_consume,
    'max_consume': params.max_consume,
    'page': params.page,
    'limit': params.limit
  }
  return request({
    url: '/hospital/customer/consultation-list',
    method: 'get',
    params: data
  })
}

export function getIntentionCustomerList(params) {
  const data = {
    'search_value': params.search_key,
    'user_area': params.user_area,
    'first_source': params.first_source,
    'start_behavior_count': params.start_behavior_count,
    'end_behavior_count': params.end_behavior_count,
    'start_last_browse_time': params.start_last_browse_time,
    'end_last_browse_time': params.end_last_browse_time,
    'start_last_login_time': params.start_last_login_time,
    'end_last_login_time': params.end_last_login_time,
    'start_first_consultation_time': params.start_first_consultation_time,
    'end_first_consultation_time': params.end_first_consultation_time,
    'start_last_consultation_time': params.start_last_consultation_time,
    'end_last_consultation_time': params.end_last_consultation_time,
    'order_start_time': params.order_start_time,
    'order_end_time': params.order_end_time,
    'start_use_time': params.start_use_time,
    'end_use_time': params.end_use_time,
    'min_consume': params.min_consume,
    'max_consume': params.max_consume,
    'page': params.page,
    'limit': params.limit
  }
  return request({
    url: '/hospital/customer/intention-list',
    method: 'get',
    params: data
  })
}

export function getCustomer(id) {
  const data = {
    'customer_id': id
  }
  return request({
    url: '/hospital/customer/info',
    method: 'get',
    params: data
  })
}

export function updateCustomer(params) {
  const data = {
    customer_id: params.customer_id ? params.customer_id : undefined,
    profession: params.profession ? params.profession : '',
    specific_disease_history: params.specific_disease_history ? params.specific_disease_history : '',
    allergy_history: params.allergy_history ? params.allergy_history : '',
    pharmacy_history: params.pharmacy_history ? params.pharmacy_history : '',
    age: params.age ? params.age : 0,
    consume_level: params.consume_level ? params.consume_level : '',
    hobby: params.hobby ? params.hobby : '',
    face_lift_history: params.face_lift_history ? params.face_lift_history : '',
    intention_project: params.intention_project ? params.intention_project : '',
    user_comment: params.user_comment ? params.user_comment : '',
    customer_attribute: params.customer_attribute ? params.customer_attribute : ''
  }
  return request({
    url: '/hospital/customer/update',
    method: 'post',
    data: { ...data }
  })
}

/**
 * 获取用户信息
 * @param id
 */
export function getUserInfo(id) {
  const data = {
    'user_id': id
  }
  return request({
    url: '/hospital/user/collection',
    method: 'get',
    params: data
  })
}

/**
 * 获取客户的行为记录
 * @param params
 */
export function getCustomerBehavior(params) {
  const data = {
    'user_id': params.user_id,
    'start_created_at': params.start_created_at ? params.start_created_at : undefined,
    'end_created_at': params.end_created_at ? params.end_created_at : undefined,
    'page': params.page ? params.page : 1
  }
  return request({
    url: '/hospital/behavior',
    method: 'get',
    params: data
  })
}
/**
 * [getCustomerInfo 用user_id获取客户资料，另一个接口]
 *
 * @param  {[user_id]}
 */
export function getCustomerInfo(user_id) {
  return request({
    url: '/hospital/customer/get-customer-info',
    method: 'get',
    params: { user_id }
  })
}

/**
 * 获取私信马甲信息
 * @param {[user_id]}
 */

export function getHookUserInfo(hook_user_id) {
  return request({
    url: '/hospital/get-hook-user-info',
    method: 'get',
    params: { hook_user_id }
  })
}
